import Vue from 'vue'

var utils=function(){
	add=function(){
		const loading = Vue.prototype.$loading({
			lock: true,
			text: 'Loading',
			spinner: 'el-icon-loading',
			background: 'rgba(0, 0, 0, 0.7)'
		});
		setTimeout(() => {
			loading.close();
		}, 2000);
	},
	loading=function(){
		Vue.prototype.$loading({
			lock: true,
			text: 'Loading',
			spinner: 'el-icon-loading',
			background: 'rgba(0, 0, 0, 0.7)'
		});
	},
	confirm=function(content,confirm){
		Vue.prototype.$alert(content,'提示', {
			confirmButtonText: '确定',
			callback: action => {
				if(action=='confirm'){
					confirm(action)
				};
			}
		});
	},
	message=function(content,message){
		Vue.prototype.$alert(content,'提示', {
			callback: action => {
				if(action=='confirm'){

				}
			}
		});
	},
	customize=function(content,title,confirm){
		Vue.prototype.$alert(content, title, {
			dangerouslyUseHTMLString: true,
			confirmButtonText: '确定',
			cancelButtonText:'取消',
			callback: action => {
				if(action=='confirm'){
					confirm(action)
				}
			}
		});
	},
	date=function(fmt){
		let date=new Date();
			var o = {
				"M+": date.getMonth() + 1, //月份
				"d+": date.getDate(), //日
				"H+": date.getHours(), //小时
				"m+": date.getMinutes(), //分
				"s+": date.getSeconds(), //秒
				"q+": Math.floor((date.getMonth() + 3) / 3), //季度
				"S": date.getMilliseconds() //毫秒
			};
			if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
			for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
			return fmt;
	},
	time=function(){
		let date=new Date();
		let day=date.getDay();
		if(day==0){
			day='日';
		}else if(day==1){
			day='一';
		}else if(day==2){
			day='二';
		}else if(day==3){
			day='三';
		}else if(day==4){
			day='四';
		}else if(day==5){
			day='五';
		}else{
			day='六';
		}
		return day;
	}


}
export{
  utils,
}
